masterofmagicfandomcom-20200216-history
Talk:Movement Allowance/@comment-172.218.219.209-20160113060018/@comment-27183706-20160228175229
It's a problem because 1. A movement into a cell for the player is allowed if they have movement greater than the amount needed to travel to that cell minus the cost of entering the cell itself. So if there is 0.5 movement left before entering it, it's fine. This is true regardless of distance, even if you are moving into the adjacent cell. So step by step movement is affected. The code doesn't store which direction we are entering that cell from. It merely stores "it costs X to reach this on the shortest path". So there is no way to actually subtract the diagonal cost of the last step since it's not stored and I can't just pull out a 20x20 matrix for storing that data out of nowhere. Which means that a unit with 0.5 movement will be unable to move diagonally at all (since the 1.5-1 cost would not be lower than the remaining 0.5 movement, and there is no easy way to correctly calculate 1.5-1.5 instead for paths ending in a diagonal), or even attack the unit diagonally from it. This would result in units that have a total movement of 1 being unable to attack twice a turn diagonally. 2. When the AI priorizes targets and looks at the distance of units, it's calculating distance=max(X distance, Y distance) in other words assumes diagonals cost 1. I could probably alter this one but it's extra work and pointless if 1 remains broken. 3. I have no idea how the entire thing would interact with the terrain. Which can make the "shorter" valid path actually more expensive, so I can't just say "always take the diagonal part of the movement last", not that I could even do that by hex editing assembly code in the first place. 4. Any solutions would still cause inconsistency between AI and human behavior, since AI is "random" to begin with, moving more or less depending on which direction it does first. 5. I definitely want to avoid inconsistent behavior on the player's side. If someone sees "I can't move the same distance on the same terrain to the left, as to the right" they'll think "this is a bug". Even more so than the current behavior which is still bad but at least is in the player's favor, not against him. I believe having all directions cost 1 is a fine, simple solution that gets rid of all of the above problems. I haven't tested in practice but I think it should also make it harder to run in circles if the units have equal speed, not impossible though. In combat, you can't do multiple turns of movement in one go, so that algorithm is not possible or relevant. On the overland map, yes that would be nice, problem is...the maximum movement of the stack, or even the current movement is not passed down as a parameter to the pathfinder algorithm, so we have no way of knowing when the turn "ends" for moves. What's worse, a lot of places calling it don't even have this data themselves so I can't even edit them to pass it to the procedure. The only information to work with is the matrix which contains the movement cost of entering each tile on the overland map for the movement type of the stack currently trying to move (and -1s for invalid squares, like water for land units).